import request from '@/utils/request'

// 设备列表
export const getDeviceList = (params) => {
  return request({
    method: 'get',
    url: '/data/equipment/query',
    params: params,
  })
}

// 设备统计
export const getDeviceStatistics = (params) => {
  return request({
    method: 'get',
    url: '/data/equipment/query/total',
    params: params,
  })
}

// 场景列表
export const getSceneList = (params) => {
  return request({
    method: 'get',
    url: '/data/equipment/scene/query',
    params: params,
  })
}
// 新增场景
export const sceneAdd = (params) => {
  return request({
    method: 'post',
    url: '/data/equipment/scene/addOrUpdate',
    data: params,
  })
}
// 删除场景
export const sceneDelete = (params) => {
  return request({
    method: 'delete',
    url: '/data/equipment/scene/delete',
    params: params,
  })
}
// 场景详情
export const sceneDetail = (params) => {
  return request({
    method: 'get',
    url: '/data/equipment/scene/get',
    params: params,
  })
}

/**
 * 获取摄像机设备列表
 */
export const fetchCameraDeviceList = (params) => {
  return request({
    method: 'get',
    url: '/device/camera/list',
    params: params,
  })
}

/**
 * 获取摄像机设备详情
 */
export const fetchCameraDeviceDetail = (pkid) => {
  return request({
    method: 'get',
    url: `/device/camera/get?pkid=${pkid}`,
  })
}

/**
 * 编辑摄像机设备
 */
export const updateCameraDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/camera/update',
    data: params,
  })
}

/**
 * 获取萤石云摄像机设备列表
 */
export const fetchYsyCameraDeviceList = (params) => {
  return request({
    method: 'get',
    url: '/device/ys/listCamera',
    params: params,
  })
}

/**
 * 编辑萤石云摄像机设备
 */
export const updateYsyCameraDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/ys/updateCamera',
    data: params,
  })
}

/**
 * 获取萤石云摄像机设备详情
 */
export const fetchYsyCameraDeviceDetail = (pkid) => {
  return request({
    method: 'get',
    url: `/device/ys/getCamera?pkid=${pkid}`,
  })
}

/**
 * 获取nvr设备列表
 */
export const fetchNvrDeviceList = (params) => {
  return request({
    method: 'get',
    url: '/device/nvr/list',
    params: params,
  })
}

/**
 * 添加nvr设备
 */
export const addNvrDevice = (params) => {
  return request({
    method: 'post',
    url: '/device/nvr/add',
    data: params,
  })
}

/**
 * 编辑nvr设备
 */
export const updateNvrDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/nvr/update',
    data: params,
  })
}

/**
 * 删除nvr设备
 */
export const deleteNvrDevice = (params) => {
  return request({
    method: 'delete',
    url: '/device/nvr/delete',
    params: params,
  })
}

/**
 * 打开视频流
 */
export const openCameraStream = (pkid) => {
  return request({
    method: 'get',
    url: `/device/camera/openHls?pkid=${pkid}`,
  })
}

/**
 * 关闭视频流
 */
export const closeCameraStream = (pkid) => {
  return request({
    method: 'get',
    url: `/device/camera/stopHls?pkid=${pkid}`,
  })
}

/**
 * 关闭所有视频流
 */
export const closeAllCameraStream = () => {
  return request({
    method: 'get',
    url: '/device/camera/stopAllHls',
  })
}

/**
 * 查询有录像的日期
 *
 * @param params {object} 请求参数
 * @param params.pkid {string} 摄像头id
 * @param params.year {string} 年份
 * @param params.month {string} 月份
 */
export const queryVideoDate = (params) => {
  return request({
    method: 'get',
    url: '/device/camera/playback/dailyDistribution',
    params: params,
  })
}

/**
 * 查询有录像时间范围
 *
 * @param params {object} 请求参数
 * @param params.pkid {string} 摄像头id
 * @param params.startTime {string} 开始时间
 * @param params.endTime {string} 结束时间
 */
export const queryVideoTimeRange = (params) => {
  return request({
    method: 'get',
    url: '/device/camera/playback/search',
    params: params,
  })
}

/**
 * 获取录像指定时间视频流
 *
 * @param params {object} 请求参数
 * @param params.pkid {string} 摄像头id
 * @param params.startTime {string} 开始时间
 */
export const queryVideoPlaybackStream = (params) => {
  return request({
    method: 'get',
    url: '/device/camera/playback/play',
    params: params,
  })
}

/**
 * 获取存储服务器设备列表
 */
export const fetchStorageDeviceList = (params) => {
  return request({
    method: 'get',
    url: '/device/storage/list',
    params: params,
  })
}

/**
 * 添加存储服务器设备
 *
 * @param {object} params 参数
 * @param {string} params.nickname 设备昵称
 * @param {string} params.ip 设备ip
 * @param {string} params.post 设备端口
 * @param {string} params.username 设备用户名
 * @param {string} params.password 设备密码
 */
export const addStorageDevice = (params) => {
  return request({
    method: 'post',
    url: '/device/storage/add',
    params: params,
  })
}

/**
 * 编辑存储服务器设备
 */
export const updateStorageDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/storage/update',
    data: params,
  })
}

/**
 * 删除存储服务器设备
 */
export const deleteStorageDevice = (params) => {
  return request({
    method: 'delete',
    url: '/device/storage/delete',
    params: params,
  })
}

/**
 * 获取存储服务器频道
 */
export const fetchStorageDeviceChannels = (pkid) => {
  return request({
    method: 'get',
    url: `/device/storage/getChannels?pkid=${pkid}`,
  })
}

/**
 * 获取存储服务器视频播放路径
 *
 * @param {object} param 参数
 * @param {string} param.pkid 设备pkid
 * @param {string} param.channel 频道
 * @param {string} param.startTime 开始时间
 * @param {string} param.endTime 结束时间
 */
export const fetchStorageDevicePlayback = (params) => {
  return request({
    method: 'get',
    url: '/device/storage/playback',
    params: params,
  })
}

/**
 * 获取闸机设备列表
 */
export const fetchCarGateDeviceList = (params) => {
  return request({
    method: 'get',
    url: '/device/vehicleGate/list',
    params: params,
  })
}

/**
 * 添加闸机设备
 */
export const addCarGateDevice = (params) => {
  return request({
    method: 'post',
    url: '/device/vehicleGate/add',
    data: params,
  })
}

/**
 * 编辑闸机设备
 */
export const updateCarGateDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/vehicleGate/update',
    data: params,
  })
}

/**
 * 删除闸机设备
 */
export const deleteCarGateDevice = (params) => {
  return request({
    method: 'delete',
    url: '/device/vehicleGate/delete',
    params: params,
  })
}

/**
 * 获取车牌列表
 */
export const fetchCarPlateList = (params) => {
  return request({
    method: 'get',
    url: '/device/vehicleGate/listPlate',
    params: params,
  })
}

/**
 * 添加车牌
 */
export const addCarPlate = (params) => {
  return request({
    method: 'post',
    url: '/device/vehicleGate/addPlate',
    data: params,
  })
}

/**
 * 编辑车牌
 */
export const updateCarPlate = (params) => {
  return request({
    method: 'put',
    url: '/device/vehicleGate/updatePlate',
    data: params,
  })
}

/**
 * 删除车牌
 */
export const deleteCarPlate = (params) => {
  return request({
    method: 'delete',
    url: '/device/vehicleGate/delPlate',
    data: params,
  })
}

/**
 * 获取门磁人脸识别机设备列表
 */
export const fetchMagnetFaceDeviceList = (params) => {
  return request({
    method: 'get',
    url: '/device/faceDoor/list',
    params: params,
  })
}

/**
 * 添加门磁人脸识别机设备
 */
export const addMagnetFaceDevice = (params) => {
  return request({
    method: 'post',
    url: '/device/faceDoor/add',
    data: params,
  })
}

/**
 * 编辑门磁人脸识别机设备
 */
export const updateMagnetFaceDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/faceDoor/update',
    data: params,
  })
}

/**
 * 删除门磁人脸识别机设备
 */
export const deleteMagnetFaceDevice = (params) => {
  return request({
    method: 'delete',
    url: '/device/faceDoor/delete',
    params: params,
  })
}

/**
 * 获取门磁人脸识别机人脸
 */
export const fetchMagnetFaceList = (params) => {
  return request({
    method: 'get',
    url: '/device/faceDoor/listPerson',
    params: params,
  })
}

/**
 * 添加门磁人脸识别机人脸
 */
export const addMagnetFace = (params) => {
  return request({
    method: 'post',
    url: '/device/faceDoor/addPerson',
    data: params,
  })
}

/**
 * 编辑门磁人脸识别机人脸
 */
export const updateMagnetFace = (params) => {
  return request({
    method: 'put',
    url: '/device/faceDoor/updatePerson',
    data: params,
  })
}

/**
 * 删除门磁人脸识别机人脸
 */
export const deleteMagnetFace = (params) => {
  return request({
    method: 'delete',
    url: '/device/faceDoor/delPerson',
    data: params,
  })
}

/**
 * 获取翼闸人脸识别机设备列表
 */
export const fetchFaceDeviceList = (params) => {
  return request({
    method: 'get',
    url: '/device/pedestrian/list',
    params: params,
  })
}

/**
 * 添加翼闸人脸识别机设备
 */
export const addFaceDevice = (params) => {
  return request({
    method: 'post',
    url: '/device/pedestrian/add',
    data: params,
  })
}

/**
 * 编辑翼闸人脸识别机设备
 */
export const updateFaceDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/pedestrian/update',
    data: params,
  })
}

/**
 * 删除翼闸人脸识别机设备
 */
export const deleteFaceDevice = (params) => {
  return request({
    method: 'delete',
    url: '/device/pedestrian/delete',
    params: params,
  })
}

/**
 * 获取翼闸人脸识别机人脸
 */
export const fetchFaceList = (params) => {
  return request({
    method: 'get',
    url: '/device/pedestrian/listPerson',
    params: params,
  })
}

/**
 * 添加翼闸人脸识别机人脸
 */
export const addFace = (params) => {
  return request({
    method: 'post',
    url: '/device/pedestrian/addPerson',
    data: params,
  })
}

/**
 * 编辑翼闸人脸识别机人脸
 */
export const updateFace = (params) => {
  return request({
    method: 'put',
    url: '/device/pedestrian/updatePerson',
    data: params,
  })
}

/**
 * 删除翼闸人脸识别机人脸
 */
export const deleteFace = (params) => {
  return request({
    method: 'delete',
    url: '/device/pedestrian/delPerson',
    data: params,
  })
}

/**
 * 同步gnss数据
 */
export const syncGnssData = (params) => {
  return request({
    method: 'get',
    url: '/device/gnss/syncDevice',
    params: params,
  })
}

/**
 * 获取gnss项目数据
 */
export const fetchGnssProject = (params) => {
  return request({
    method: 'get',
    url: '/device/gnss/listProject',
    params: params,
  })
}

/**
 * 编辑gnss项目
 */
export const updateGnssProject = (params) => {
  return request({
    method: 'put',
    url: '/device/gnss/updateProject',
    data: params,
  })
}

/**
 * 获取gnss点位数据
 */
export const fetchGnssPoint = (params) => {
  return request({
    method: 'get',
    url: '/device/gnss/listPoint',
    params: params,
  })
}

/**
 * 获取gnss传感器数据
 */
export const fetchGnssSensor = (params) => {
  return request({
    method: 'get',
    url: '/device/gnss/listSensor',
    params: params,
  })
}

/**
 * 编辑gnss传感器
 */
export const updateGnssSensor = (params) => {
  return request({
    method: 'put',
    url: '/device/gnss/updateSensor',
    data: params,
  })
}

/**
 * 获取gnss传感器历史数据
 */
export const fetchGnssSensorHistoryData = (params) => {
  return request({
    method: 'get',
    url: '/device/gnss/sensorHistory',
    params: params,
  })
}

/**
 * 同步静态检测设备数据
 */
export const syncStaticMonitorDeviceData = (params) => {
  return request({
    method: 'get',
    url: '/device/collecting/syncStaticDevice',
    params: params,
  })
}

/**
 * 获取静态检测设备
 */
export const fetchStaticMonitorDevice = (params) => {
  return request({
    method: 'get',
    url: '/device/collecting/listStaticDevice',
    params: params,
  })
}

/**
 * 编辑静态检测设备
 */
export const updateStaticMonitorDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/collecting/updateStaticDevice',
    data: params,
  })
}

/**
 * 获取静态检测设备数据
 */
export const fetchStaticMonitorDeviceData = (params) => {
  return request({
    method: 'get',
    url: '/device/collecting/listStaticDeviceData',
    params: params,
  })
}

/**
 * 同步报警设备数据
 */
export const syncAlertDeviceData = (params) => {
  return request({
    method: 'get',
    url: '/device/aep/syncDevice',
    params: params,
  })
}

/**
 * 获取报警设备
 */
export const fetchAlertDevice = (params) => {
  return request({
    method: 'get',
    url: '/device/aep/listDevice',
    params: params,
  })
}

/**
 * 编辑报警设备
 */
export const updateAlertDevice = (params) => {
  return request({
    method: 'put',
    url: '/device/aep/updateDevice',
    data: params,
  })
}

/**
 * 获取报警设备数据
 */
export const fetchAlertDeviceData = (params) => {
  return request({
    method: 'get',
    url: '/device/aep/listEvent',
    params: params,
  })
}
